package com.mlnx.yingbaisui.device.leida;

import io.netty.channel.ChannelHandlerContext;
import org.shan.iot.handler.NettyByteDecoder;
import org.shan.iot.handler.RequestHandle;
import org.shan.iot.protocol.ReqRepMsg;
import org.shan.iot.server.tcp.DefaultNettyTcpNetwork;

import java.net.InetSocketAddress;
import java.net.SocketAddress;

public class TestDeviceServer extends DefaultNettyTcpNetwork {
    public TestDeviceServer(SocketAddress localAddress) {
        super(localAddress);
    }

    @Override
    protected NettyByteDecoder getNettyByteDecoder() {
        return new TestNettyServerDecoder();
    }

    @Override
    protected RequestHandle getRequestHandle() {
        return new RequestHandle() {
            @Override
            protected void channelRead0(ChannelHandlerContext ctx, ReqRepMsg msg) throws Exception {

                // 对数据进行处理

            }
        };
    }

    public static void main(String[] args) throws Exception {

        TestDeviceServer server = new TestDeviceServer(new InetSocketAddress(7878));
        server.init();
        server.start();
    }
}
